var Tabs = require('common:components/tabs/tabs');
var tab = new Tabs({
    element: '#zbj-tabs-demo',
    triggers: '#zbj-tabs-demo .zbj-tabs li',
    panels: '#zbj-tabs-demo .zbj-tabs-content .zbj-tabs-panel',
    activeIndex: 0
});

tab.on('switch', function( toIndex, fromIndex ){
    console.log('to switch to ' + toIndex);
});

tab.on('switched', function( toIndex, fromIndex ){
    console.log('switched to ' + toIndex);
});
var flag="";
$("li",".zbj-tabs-nav").click(function(){
    var str=$(this).attr("id");
    if(flag!=str){
        flag=str;
        var type=str.charAt(str.length-1);
        var target=$(".zbj-tabs-panel")[type];
        var text=$(".zbj-tabs-content").attr("text-loading")
        target.innerHTML='<i class="icon-loading"></i><span class="text-loading">'+text+'</span></i>';
        $.ajax({
            async: true,
            url : "http://rap.zbjwork.com/mockjsdata/54/task/?page=1&type="+type,
            success : function(responseText) {
                var tmpl=require("city:widget/task/ui-tab/tmpl/tpl.gov-require-content.tmpl")(responseText.listData);
                target.innerHTML=tmpl;
            }
        });

    }
});